package com.hikvision.cms.service.serviceimpl;

import com.hikvision.cms.dao.AcsEventMapper;
import com.hikvision.cms.dao.EventDisMapper;
import com.hikvision.cms.domain.AcsEvent;
import com.hikvision.cms.domain.EventDis;
import com.hikvision.cms.dto.EventDisDto;
import com.hikvision.cms.service.PlaneService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class PlaneServiceImpl
        implements PlaneService {
    @Autowired
    private EventDisMapper eventDisMapper;
    @Autowired
    private AcsEventMapper acsEventMapper;

    public EventDisDto getEventDisDtoBean() {
        /* 24 */
        EventDis eventDis = this.eventDisMapper.selectMaxId();
        /* 25 */
        if (eventDis == null) {
            /* 26 */
            return null;
        }
        /* 28 */
        AcsEvent acsEvent = this.acsEventMapper.selectByPrimaryEvenId(eventDis.getId());
        /* 29 */
        if (acsEvent == null) {
            /* 30 */
            return null;
        }
        /* 32 */
        EventDisDto eventDisDto = new EventDisDto();
        /* 33 */
        BeanUtils.copyProperties(eventDis, eventDisDto);
        /* 34 */
        eventDisDto.setAcsEvent(acsEvent);
        /* 35 */
        return eventDisDto;
    }


    public Integer deleteById(Integer id) {
        /* 40 */
        AcsEvent acsEvent = new AcsEvent();
        /* 41 */
        acsEvent.setEventId(id);
        /* 42 */
        this.acsEventMapper.deleteById(acsEvent);
        /* 43 */
        EventDis eventDis = new EventDis();
        /* 44 */
        eventDis.setId(id);
        /* 45 */
        int i = this.eventDisMapper.deleteById(eventDis);
        /* 46 */
        return Integer.valueOf(i);
    }
}

